const data = [
  { name: "js", price: 100 },
  { name: "mysql", price: 212 },
  { name: "vue.js", price: 398 }
];

class Lesson {
  constructor(data) {
    this.model = data
  }

  static createBatch(data) {
   return data.map(item => new Lesson(item))
  }

  static MaxPrice(lessons) {
    return lessons.sort((a, b) => b.model.price - a.model.price)[0].model.price
  }

  // retType, row(一行), column(一列) ，one(一个单元格)
  static MaxPrice2(lessons, retType='row') {
    var field  = 'price'
    var fn = function(item) {
      return retType === 'one' ? item.model[field] : item.model
    }
    return lessons.map(fn)
  }
  static MaxPrice3(lessons) {
    var field  = 'price'
    var fn = function(item) {
      return field ? item.model[field] : item.model
    }
    return Math.max.apply(null, lessons.map(fn))
  }
  
}


const lessons = Lesson.createBatch(data);
console.log(lessons);
console.log(Lesson.MaxPrice(lessons));
console.log(Lesson.MaxPrice2(lessons));
console.log(Lesson.MaxPrice3(lessons));